import torch
from torch import nn
from torch.nn import functional as F
import os

import sys
sys.path.append("../../py")
from utils import save_tensor_as_text

TXT_PARAM_DIR = "txt_param"
if __name__ == '__main__':
    if not os.path.exists(TXT_PARAM_DIR):
        os.mkdir(TXT_PARAM_DIR)
    with torch.no_grad():
        img = torch.randn(512, 4, 4)
        out = F.adaptive_avg_pool2d(img, 1)
        def _save_tensor_as_text(t, p):
            save_tensor_as_text(t, os.path.join(TXT_PARAM_DIR,p))
        _save_tensor_as_text(img, "img_avg_pool2d_test.txt")
        _save_tensor_as_text(out, "out_avg_pool2d_test.txt")
        